package com.spring.test_back_end.bean;

import com.alibaba.fastjson.JSONObject;

public class Ret {

    private final int code;
    private String msg;
    private Object data;
    private String err;


    public Object getData() {
        return data;
    }


    public int getCode() {
        return code;
    }


    public String getMsg() {
        return msg;
    }

    public String getErr() {
        return err;
    }


    public static class Builder {
        private final int code;
        private String msg;
        private Object data;
        private String err;


        public Builder(RetCode code) {
            this.code = code.getCode();
        }

        public Builder msg(String msg) {
            this.msg = msg;
            return this;
        }

        public Builder err(String err) {
            this.err = err;
            return this;
        }

        public Builder data(Object data) {
            this.data = data;
            return this;
        }

        public Ret build() {
            return new Ret(this);
        }
    }

    private Ret(Builder builder) {
        this.data = builder.data;
        this.code = builder.code;
        this.msg = builder.msg;
        this.err = builder.err;
    }

    @Override
    public String toString() {
        return JSONObject.toJSONString(this);
    }
}
